package dao.impl;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import dao.UseCarRecordDao;
import po.car.UseCarRecord;

public class UseCarRecordDaoImpl implements UseCarRecordDao{
	private List<UseCarRecord> record;

	public UseCarRecordDaoImpl() {
		List<UseCarRecord> record = new LinkedList<UseCarRecord>();
	}

	@Override
	public boolean insert(Object t) {
		if(record.contains(t)) {
			return false;
		}else {
			return record.add((UseCarRecord) t);
		}
	}

	@Override
	public boolean update(Object t) {
		int index = record.indexOf(t);
		if (index == - 1) {
			return false;
		}else {
			record.set(index, (UseCarRecord) t);
			return true;
		}
		
	}

	@Override
	public boolean delete(int id) {
		Iterator<UseCarRecord> it = record.iterator();
		while (it.hasNext()) {
			UseCarRecord s = (UseCarRecord) it.next();
			if (s.getUseId() == id) {
				it.remove();
				return true;
			}
		}
		return false;
	}

	@Override
	public Object selectById(int id) {
		for (UseCarRecord use : record) {
			if (use.getUseId() == id) {
				return use;
			}
		}
		return null;
	}

	@Override
	public List selectAll() {
		List<UseCarRecord> u = new LinkedList<UseCarRecord>();
		return u;
	}

}
